1. Field of the Invention
The present invention relates to a card-type storage medium comprising a memory built in a card-type casing, such as an IC card, and particularly, to a card-type storage medium in which destruction of files can be prevented even if an accident, such as a power interruption, occurs while data is written in the file.
2. Description of the Related Art
In recent years, IC cards have been used as media of electronic money, credit cards, ID cards, self-governing body cards and so on. In order to facilitate practical use of such IC cards, it is indispensable to establish technologies for protecting files in case power failures, errors, etc, occur while data is written in the files, as well as security technologies for preventing rewriting of files by unauthorized persons. For this purpose, various technologies have been conventionally proposed for the protection of files. These technologies are roughly divided into two types, as described below.
A first conventional technology is that a higher-class unit accessing an IC card (writing data in the file) recovery files inside the IC card. In this case, the higher-class unit keeps retaining a file to be overwritten on the IC card until the overwriting on the ID card of the file is completed, and, in case power failures or errors occur while the file is overwritten, recovers a file inside the IC card based on the file retained.
A second conventional technology is the one disclosed in Japanese Patent Application Laid-open No. Hei. 7-239928, in which a processor inside an IC card recovers a file based on recovery information prepared in advance. In this case, once a file is written inside the IC card (or overwritten), the processor inside the IC card generates recovery information consisting of data with identical composition as the file and stores the information inside the IC card. Then, when power failures or errors occur during renewal of the file, the processor copies the recovery information and overwrites it in the storage position of the original file.
However, the above mentioned conventional technologies, while accepting that an objective file is destroyed in case power failures or errors occur while data is written in the file, are used for the purpose of restoring the file after the destruction of the file. Therefore, various problems, as mentioned hereinafter, arise. This means that, according to the above-mentioned first conventional technology, since a normal file cannot exist inside an IC card until a file is recovered by a higher-class unit, the IC card becomes absolutely unavailable until the recovery. In addition, according to the above-mentioned second conventional technology, although data is recovered autonomically at the time when an IC card is supplied power again, since the recovery information must include data of the entire original file, the data volume to be retained by the IC card becomes enormous. For this reason, such problems as the delay of a response has become significant because of the increase of time required for a file search or the increase of time for preparing recovery information.
Further, in case a memory of an IC card is a flash memory, writing of data in a file retained by a certain storage area may be impossible due to the expired life of an element in the storage area. In such a case, backups have been conventionally executed in ways such that an application program of a higher-class unit rearranges the entire file by removing the storage area impossible to be written in or transfers the entire file to another IC card while the original IC card is treated as an invalid medium. For this reason, autonomical restoring by an IC card itself has been impossible, which has resulted in the increase of load for the higher-class unit.
The present invention has been made in view of the above described circumstances, and therefore, a first object of the present invention is to provide a card-type storage medium which can prevent the destruction itself of a file in case power failures, errors, etc, occur while data is written in the file inside the storage medium; prevent the increase of data volume retained by the storage medium and improve a response to a higher-class unit.
A second object of the present invention is to provide a card-type storage medium in which autonomic rearrangement of a file becomes possible inside the storage medium even in case writing of data in a certain storage area becomes impossible due to the expired life of an element, etc.
According to a first aspect of the present invention, a card-type storage medium is provided for attaining the above mentioned first object. The card-type storage medium is detachably connected to a higher-class unit writing data into the media. The card-type storage medium is comprised of a first non-volatile storage area storing data, a second non-volatile storage area temporarily storing data input by the higher-class unit, and a writing element which writes the data stored in the second non-volatile storage area into the first non-volatile storage area when the storing of data into the second non-volatile storage area by the higher-class unit is completed.
According to the first aspect of the present invention, in a card-type storage medium composed as mentioned above, a second non-volatile storage area in which data input by the higher-class unit is stored temporarily is prepared as well as a first non-volatile storage area for storing data to be read by the higher-class unit. The writing element writes data stored in the second non-volatile storage area into the first non-volatile storage area after the data input by the higher-class unit is completely stored in the second non-volatile storage area. Therefore, even if a power interruption occurs while data is input to a card-type non-volatile storage medium by the higher-class unit, since data inside the second non-volatile storage area is merely destroyed and data actually stored in the first non-volatile storage area is never destroyed, the higher-class unit can refer to data stored in the first non-volatile storage area and the card can be continuously used as it is. Further, once data is completely stored normally in the second non-volatile storage area, even if a power interruption occurs the writing element can write the data stored inside the second non-volatile storage area into the first non-volatile storage area without requiring recovery processing by the higher-class unit. In addition, since the second non-volatile storage area need not retain all the data stored inside the first non-volatile memory area and may only store the data input by the higher-class unit, the data volume to be retained within the entire card-type non-volatile storage medium never becomes excessive. Moreover, once the higher-class unit inputs data into the second non-volatile storage area, the higher-class unit can take a next action immediately because it is exempted from the duty of recovering, etc, thereafter. This means that a response to the higher-class unit is improved.
A card-type storage medium may take, for example, the form of a PC card according to PCMCIA. A higher-class unit to which the card-type storage medium is connected detachably may be a computer which can write data into and read data from the card-type storage medium. As an example of such a computer, a computer used for a electronic money system is given. In addition, a higher-class unit may be a computer which can write data only in a card-type storage medium and a computer which can read data only from a card-type storage medium. Examples of such computers are computers for a credit card system and a self-governing body card system.
A first non-volatile storage area and a second non-volatile storage area may be established either on the same semiconductor device or on independent semiconductor devices. An element may be, for example, a flash memory or an E2 ROM.
According to a second aspect of the present invention, in the above-described card-type storage medium, the above mentioned writing element writes the data stored in the second non-volatile storage area into the first non-volatile storage area when the writing element is powered-up. When composed like this, even if the supply of power to the card-type storage medium is interrupted while the writing element writes data stored in the second non-volatile storage area into the first non-volatile storage area, since data left in the second non-volatile storage area is written into the second non-volatile storage area automatically by the writing element upon the power supplied again, re-operation of the card-type storage medium becomes possible without making a user aware that the data inside the first non-volatile storage area has been destroyed by the power interruption. Further, it is not necessary to again supply power to the card-type storage medium by a higher-class unit connected to the card-type storage medium at the time of a power interruption, but the writing element can write data even if power is supplied by any other apparatuses.
According to a third aspect of the present invention, the card-type storage medium is further comprised of a data storing completion notifying element, which, upon finishing storing the data input by a higher-class unit into the second non-volatile storage area, notifies the higher-class unit of the completion of data storing, and the above-mentioned writing element writes the data stored in the second non-volatile storage area in the first non-volatile storage area after the completion of data storing is notified to the higher-class unit by the data storing completion notifying element. When composed like this, the higher-class unit can be made aware that the recovery to the card-type storage medium is no longer necessary.
According to a fourth aspect of the present invention, in the card-type storage medium, the first non-volatile storage area and the second non-volatile storage area are established on the same non-volatile memory.
According to a fifth aspect of the present invention, in the above-described card-type storage medium, the first non-volatile storage area and the second non-volatile storage area are divided into multiple sectors, respectively, and the above-mentioned writing element writes the data stored in each of the sectors in the second non-volatile storage area into any of the sectors in the first non-volatile storage area.
According to a sixth aspect of the present invention, the card-type storage medium is further comprised of an identifying element which identifies, for each sector of the second non-volatile storage area, whether or not writing of data stored in the sector into the first non-volatile storage area has been completed, and the above-mentioned writing element writes the data stored therein into any sector of the first non-volatile storage area, only for a sector of the second non-volatile storage area for which the identifying element identifies that writing of the data stored therein into the first non-volatile storage area has not been completed. When composed like this, since the writing element may not write again the data which has already been completed to be written to the second non-volatile storage area, processing times are shortened.
According to a seventh aspect of the present invention, in the card-type storage medium, data stored in the above-mentioned first non-volatile storage area is composed of a plurality of files and is doubled only for a portion of the files. When composed like this, since only important files are doubled, the risk of losing data can be prevented.
According to an eighth aspect of the present invention, a card-type storage medium is composed in order to attain the second object as well as above-mentioned first object, and the card-type storage medium is further comprised of a determining element which determines whether or not writing of data into a certain sector is possible and a substitutional sector layout element which specifies any of the unused sectors in the first non-volatile storage area as a substitutional sector and makes the writing element write the data in substitutional sector when writing of data into the sector is determined to be impossible by the determining element. When composed like this, the substitutional sector layout element can lay out an unused sector as a substitutional sector into which the determining element has determined data writing is impossible. Therefore, even if a portion of sectors in the first non-volatile storage area become unavailable due to expired life, etc., autonomical rearrangement of a file inside the card-type storage medium is possible without requiring rearrangement of the file by a higher-class unit.
According to a ninth aspect of the present invention, the card-type storage medium is further comprised of an unused sector managing element which manages unused sectors inside the first non-volatile storage area, and the substitutional sector layout element which specifies one of the unused sectors managed by the unused sector managing element as the substitutional sector.
According to a tenth aspect of the present invention, in the card-type storage medium, a sector existing in a specific position of the above-mentioned first non-volatile storage area is secured for a substitutional sector in advance and the substitutional sector layout element specifies one of the sectors secured for the substitutional sector as the substitutional sector.
According to an eleventh aspect of the present invention, in the card-type storage medium, the above-mentioned substitutional sector layout element has a correspondence table showing the corresponding relations of the substitutional sector to the unavailable sector as to which writing of the data has been determined to be impossible by the determining element. When composed like this, a program accessing the first non-volatile storage area can be aware of the substitutional sector laid out to the sector which has become unavailable by referring to the correspondence table.
According to a twelfth aspect of the present invention, in the card-type storage medium, the above-mentioned unused sector managing element has a status displaying area prepared for each sector inside the first non-volatile storage area for indicating whether the corresponding sector is in use, not in use, or unavailable.
According to a thirteenth aspect of the present invention, the card-type storage medium is comprised of, for each sector inside the first non-volatile storage area, a first pointer displaying area showing a pointer of a sector right before the object sector and a second pointer displaying area showing a pointer of a sector right after the object sector, and the substitutional sector layout element, when specifying a substitutional sector for an unavailable sector, changes indication of the status displaying area for the unavailable sector to indicate being unavailable, displays a pointer of the substitutional sector in the second pointer displaying area of the sector whose pointer is shown by the first pointer displaying area of the unavailable sector, and displays a point of the substitutional sector in the first pointer displaying area of the sector whose pointer is shown by the second pointer displaying area of the unavailable sector.
According to a fourteenth aspect of the present invention, the card-type storage medium is comprised of, for each sector inside the first non-volatile storage area, an area for displaying total number of times of data writing in the sector, and the determining element which determines a sector of which total number of times of data writing displayed in the rear for displaying the number of times of writing is equal to the predetermined number of times or more as a unavailable sector.
According to a fifteenth aspect of the present invention, in the card-type storage medium, the above-mentioned writing element carries out, prior to data writing processing to a certain sector, deletion processing to the sector, and when the time required until the completion of data deletion to a certain sector reaches the predetermined time, the above-mentioned determining element determines that the sector is unavailable.
According to a sixteenth aspect of the present invention, in the card-type storage medium, the above-mentioned writing element carries out, prior to data writing processing to a certain sector, deletion processing to the sector, and when the number of times if data deletion processing by the writing element required until the completion of data deletion in a certain sector is equal to a predetermined number of times or more, the determining element determines that the sector is unavailable.
According to a seventeenth aspect of the present invention, in the card-type storage medium, when the number of times of data writing processing by the writing element required until the completion of data writing in a certain sector is equal to or greater than the predetermined number of times the above-mentioned determining element judges that the sector is unavailable.